package com.yaozheng.vocationaltraining.adapter;

import net.sf.json.JSONArray;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.app.FragmentStatePagerAdapter;

import com.bumptech.glide.Glide;
import com.yaozheng.vocationaltraining.R;
import com.yaozheng.vocationaltraining.activity.BaseActivity;
import com.yaozheng.vocationaltraining.fragment.ItemCoursewareImageFragment;
import com.yaozheng.vocationaltraining.fragment.ItemCoursewareImageFragment_;
import com.yaozheng.vocationaltraining.fragment.ItemHomeNewsImageFragment;
import com.yaozheng.vocationaltraining.fragment.ItemHomeNewsImageFragment_;
import com.yaozheng.vocationaltraining.iview.IItemView;
import com.yaozheng.vocationaltraining.utils.BitmapLoader;
import com.yaozheng.vocationaltraining.utils.ImageUtils;
import com.yaozheng.vocationaltraining.utils.TypeUtils;

/**
 * ppt课件设备器
 *
 * @author Administrator
 */
public class ImageListCoursewareDetailAdapter extends FragmentStatePagerAdapter {

    JSONArray dataList;

    // DisplayImageOptions displayImageOptions;

    IItemView iItemView;

    boolean isFullScreen;

    String watermarkName;

    public ImageListCoursewareDetailAdapter(BaseActivity baseActivity,
                                            FragmentManager fm, JSONArray dataList, IItemView iItemView, String
                                                    watermarkName) {
        super(fm);
        this.dataList = dataList;
        this.iItemView = iItemView;
        this.watermarkName = watermarkName;
    }

    public boolean isFullScreen() {
        return isFullScreen;
    }

    public void setFullScreen(boolean isFullScreen) {
        this.isFullScreen = isFullScreen;
    }

    public JSONArray getDataList() {
        return dataList;
    }

    @Override
    public Fragment getItem(int position) {
        ItemCoursewareImageFragment imageFragment = ItemCoursewareImageFragment_
                .builder().build();

        Bundle args = new Bundle();
        args.putInt("position", position);
        args.putString("imageUrl", TypeUtils.getJsonString(dataList, position));
        args.putString("watermarkName", watermarkName);
        imageFragment.setIItemView(iItemView);
        imageFragment.setFullScreen(isFullScreen);
        imageFragment.setArguments(args);
        return imageFragment;
    }

    @Override
    public int getCount() {
        return TypeUtils.getJsonArraySize(dataList);
    }

    @Override
    public int getItemPosition(Object object) {
        return POSITION_NONE;

    }

}